//
//  LocalHtml.swift
//  WriteToLocal
//
//  Created by 郑东喜 on 2017/3/4.
//  Copyright © 2017年 郑东喜. All rights reserved.
//

import UIKit

class LocalHtml: UIViewController {
    
    lazy var tableView: UITableView = {
        let v : UITableView = UITableView.init(frame: CGRect.init(x: 0, y: 0, width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height))
        v.delegate = self;
        v.dataSource = self;
        return v
    }()
    

    lazy var webview: UIWebView = {
        let v : UIWebView = UIWebView.init(frame: CGRect.init(x: 0, y: UIScreen.main.bounds.height * 0.5 + 10, width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height * 0.5 - 20))
        
        return v
    }()
    
    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
        
        view.addSubview(webview)
        
        self.webview.loadHTMLString("<p>   The profilometer is a walk-up tool; no reservation required.<br />  <br />  Veeco Dektak 6M contact profilometer for measuring single line scan surface details. (This section to be updated...)<br />  <br />  Until then, see manual document for more information.<br />  <br />  Notifications: <br />  This is a closed group. Only a group administrator can add you.<br />  This is a closed group. Only a group administrator can add you.<br />  <br />  Training Contact: <br />  Tim Gilheart (gilheart-at-rice.edu)<br />  Rice U Fee: <br />  $8.00/use<br />  Non-Commercial / Academic Fee: <br />  $12.50/use<br />  Corporate / Commercial Fee: <br />  $40/use<br /> ", baseURL: nil)
        
        view.addSubview(tableView)
        
        self.tableView.tableFooterView = self.webview
    }
    
}


extension LocalHtml : UITableViewDelegate,UITableViewDataSource {
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        var cell = tableView.dequeueReusableCell(withIdentifier: "cellID")
        if cell == nil {
            cell = UITableViewCell.init(style: .default, reuseIdentifier: "cellUD")
            
        }
        
        cell?.textLabel?.text = "\(indexPath.row)"
        return cell!
    }
    
    func numberOfSections(in tableView: UITableView) -> Int {
        return 1
    }
    
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 3
    }
}
